/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2023-01-02
 * Time: 17:40
 */

// 编写代码, 实现线程安全版本的单例模式
public class SingletonLazy {
    private static volatile SingletonLazy instance = null;

    public SingletonLazy getInstance() {
        if (instance == null) {
            synchronized (SingletonLazy.class) {
                if (instance == null) {
                    instance = new SingletonLazy();
                }
            }
        }
        return instance;
    }

    private SingletonLazy() {}
}
